﻿#Region "License & Usage"

'Microsoft Public License (Ms-PL) 

'This license governs use of the accompanying software. If you use the 
'software, you accept this license. If you do not accept the license, do 
'not use the software. 

'1. Definitions 

'The terms "reproduce," "reproduction," "derivative works," and 
'"distribution" have the same meaning here as under U.S. copyright law. 

'A "contribution" is the original software, or any additions or changes 
'to the software. 

'A "contributor" is any person that distributes its contribution under 
'this license. 

'"Licensed patents" are a contributor's patent claims that read directly 
'on its contribution. 

'2. Grant of Rights 

'(A) Copyright Grant- Subject to the terms of this license, including the 
'license conditions and limitations in section 3, each contributor grants 
'you a non-exclusive, worldwide, royalty-free copyright license to 
'reproduce its contribution, prepare derivative works of its 
'contribution, and distribute its contribution or any derivative works 
'that you create. 

'(B) Patent Grant- Subject to the terms of this license, including the 
'license conditions and limitations in section 3, each contributor grants 
'you a non-exclusive, worldwide, royalty-free license under its licensed 
'patents to make, have made, use, sell, offer for sale, import, and/or 
'otherwise dispose of its contribution in the software or derivative 
'works of the contribution in the software. 

'3. Conditions and Limitations 

'(A) No Trademark License- This license does not grant you rights to use 
'any contributors' name, logo, or trademarks. 

'(B) If you bring a patent claim against any contributor over patents 
'that you claim are infringed by the software, your patent license from 
'such contributor to the software ends automatically. 

'(C) If you distribute any portion of the software, you must retain all 
'copyright, patent, trademark, and attribution notices that are present 
'in the software. 

'(D) If you distribute any portion of the software in source code form, 
'you may do so only under this license by including a complete copy of 
'this license with your distribution. If you distribute any portion of 
'the software in compiled or object code form, you may only do so under a 
'license that complies with this license. 

'(E) The software is licensed "as-is." You bear the risk of using it. The 
'contributors give no express warranties, guarantees or conditions. You 
'may have additional consumer rights under your local laws which this 
'license cannot change. To the extent permitted under your local laws, 
'the contributors exclude the implied warranties of merchantability, 
'fitness for a particular purpose and non-infringement.

#End Region

#Region "Options"

Option Strict On
Option Explicit On

#End Region

#Region "Imports"

'From .Net Framework 3.5
Imports Microsoft.Drawing

'From Custom Classes/Reference
Imports StedySoft.SenseSDK
Imports StedySoft.SenseSDK.DrawingCE
Imports SenseSDKExtended
Imports SenseSDKExtended.DrawingCEEx

#End Region

Public Class frm_SensePanelItemEx_HTCContactsStyle1

#Region "Fields"

    'Decalre path for various things
    Dim path_resources_root As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.Substring(0, System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.LastIndexOf("\")) & "\Resources\"

    'General Images from Resources folder
    Dim icon_contact As IImage = DrawingCE.SenseAPIs.SenseImage.LoadIImageFromFile(path_resources_root & If(DrawingCE.Resolution.ScreenIsVGA, "contact_vga", "contact_qvga") & ".png")
    Dim icon_addnew As IImage = DrawingCE.SenseAPIs.SenseImage.LoadIImageFromFile(path_resources_root & If(DrawingCE.Resolution.ScreenIsVGA, "AddNewButton.VGA", "AddNewButton.QVGA") & ".png")
    Dim icon_addressbook As IImage = DrawingCE.SenseAPIs.SenseImage.LoadIImageFromFile(path_resources_root & If(DrawingCE.Resolution.ScreenIsVGA, "AddressBookButton.VGA", "AddressBookButton.QVGA") & ".png")
    Dim icon_search As IImage = DrawingCE.SenseAPIs.SenseImage.LoadIImageFromFile(path_resources_root & If(DrawingCE.Resolution.ScreenIsVGA, "SearchButton.VGA", "SearchButton.QVGA") & ".png")
    Dim icon_arrow_right As IImage = DrawingCE.SenseAPIs.SenseImage.LoadIImageFromFile(path_resources_root & If(DrawingCE.Resolution.ScreenIsVGA, "HTCArrowStyle1.Right.Gray.VGA", "HTCArrowStyle1.Right.Gray.QVGA") & ".png")

    'Declare header control to add on top of the form
    Private s_header As SenseHeaderControl = New SenseHeaderControl

    'Declare list control to add below the header control on the form
    Private s_list As SenseListControl = New SenseListControl

    'Declare sensepanel item for information
    Private s_panelitemex As SensePanelItemEx.HTCContactsStyle4 = New SensePanelItemEx.HTCContactsStyle4
    Private s_panelitemexStyle As SensePanelItemEx.HTCContactsStyle1 = New SensePanelItemEx.HTCContactsStyle1

#End Region

#Region "Methods"

    Private Sub frm_SenseHeaderControlEx_HTCContactsStyle1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed

        'Dispose list control and header control
        s_list.Dispose()
        s_header.Dispose()

    End Sub

    Private Sub frm_SenseHeaderControlEx_HTCContactsStyle1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

        'Clear the list control
        s_list.Clear()

    End Sub

    Private Sub frm_SenseHeaderControlEx_HTCContactsStyle1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Create header control properties
        s_header.Dock = System.Windows.Forms.DockStyle.Top
        s_header.Location = New System.Drawing.Point(0, 0)
        s_header.Name = "s_header"
        s_header.Size = New System.Drawing.Size(240, 25)
        s_header.TabIndex = 0
        s_header.Text = "SenseSDK Extended Demo"

        Select Case Me.Tag.ToString

            Case "btn_frm_SensePanelItemEx_HTCContactsStyle1_1"

                s_panelitemexStyle.PrimaryText = "New"
                s_panelitemexStyle.SecondaryText = "Add a new contact"
                s_panelitemexStyle.SecondaryTextFontSize = 7
                s_panelitemexStyle.SecondaryTextForeColor = Color.FromArgb(75, 75, 75)
                s_panelitemexStyle.Name = "s_panelitemexStyle"
                s_panelitemexStyle.iThumbnailLeft = icon_addnew

                s_panelitemex.PrimaryText = "HTC Contact Book Style - Add new contact. Has Click Events on every section."
                s_panelitemex.Name = "s_panelitemex"
                s_panelitemex.iThumbnailLeft = icon_arrow_right
                s_panelitemex.PropertyTable = SensePanelItemEx.HTCContactsStyle4Options.ProcessProperties(s_panelitemex)


            Case "btn_frm_SensePanelItemEx_HTCContactsStyle1_2"

                s_panelitemexStyle.PrimaryText = "Green Hacks"
                s_panelitemexStyle.Name = "s_panelitemexStyle"
                s_panelitemexStyle.iThumbnailLeft = icon_contact

                s_panelitemex.PrimaryText = "HTC Contact Book Style - Contact name. Has Click Events on every section."
                s_panelitemex.Name = "s_panelitemex"
                s_panelitemex.iThumbnailLeft = icon_arrow_right
                s_panelitemex.PropertyTable = SensePanelItemEx.HTCContactsStyle4Options.ProcessProperties(s_panelitemex)

            Case "btn_frm_SensePanelItemEx_HTCContactsStyle1_3"

                s_panelitemexStyle.PrimaryText = "Me"
                s_panelitemexStyle.SecondaryText = "My contact card"
                s_panelitemexStyle.SecondaryTextFontSize = 7
                s_panelitemexStyle.SecondaryTextForeColor = Color.FromArgb(75, 75, 75)
                s_panelitemexStyle.Name = "s_panelitemexStyle"
                s_panelitemexStyle.iThumbnailLeft = icon_contact
                s_panelitemexStyle.iThumbnailRight = icon_addressbook

                s_panelitemex.PrimaryText = "HTC Contact Book Style - Contact name with address book. Has Click Events on every section."
                s_panelitemex.Name = "s_panelitemex"
                s_panelitemex.iThumbnailLeft = icon_arrow_right
                s_panelitemex.PropertyTable = SensePanelItemEx.HTCContactsStyle4Options.ProcessProperties(s_panelitemex)

            Case "btn_frm_SensePanelItemEx_HTCContactsStyle1_4"

                s_panelitemexStyle.PrimaryText = "Green Hacks has very very long name"
                s_panelitemexStyle.SecondaryText = "Above line was auto wrapped as it was long like this one"
                s_panelitemexStyle.SecondaryTextFontSize = 7
                s_panelitemexStyle.SecondaryTextForeColor = Color.FromArgb(75, 75, 75)
                s_panelitemexStyle.Name = "s_panelitemexStyle"
                s_panelitemexStyle.iThumbnailLeft = icon_contact

                s_panelitemex.PrimaryText = "HTC Contact Book Style - Contact name with auto wrap if long name. Has Click Events on every section."
                s_panelitemex.Name = "s_panelitemex"
                s_panelitemex.iThumbnailLeft = icon_arrow_right
                s_panelitemex.PropertyTable = SensePanelItemEx.HTCContactsStyle4Options.ProcessProperties(s_panelitemex)

        End Select



        'Create list control properties.
        s_list.Dock = System.Windows.Forms.DockStyle.Fill
        s_list.IsSecondaryScrollType = False
        s_list.Location = New System.Drawing.Point(0, 200)
        s_list.MinimumMovement = 15
        s_list.Name = "s_list"
        s_list.ShowScrollIndicator = False
        s_list.TabIndex = 1
        s_list.ThreadSleep = 100
        s_list.TopIndex = 0
        s_list.Velocity = 0.9F
        s_list.Springback = 0.35F

        'Add list control first on the form
        Me.Controls.Add(s_list)

        'Add header control second on the form
        Me.Controls.Add(s_header)

        'Sense list control beginupdates
        s_list.BeginUpdate()

        'Add sensepanel style to list control
        s_list.AddItem(s_panelitemexStyle)

        'Add a seperator
        s_list.AddItem(New SensePanelDividerItem("sep", "Description"))

        'Add sensepanel to list control
        s_list.AddItem(s_panelitemex)

        'Add button to list control
        Dim btb_close = New SensePanelButtonItem
        btb_close.Text = "Back"
        AddHandler btb_close.OnClick, AddressOf btb_close_OnClick
        s_list.AddItem(btb_close)

        'End updates of sense list control
        s_list.EndUpdate()

    End Sub

    Private Sub btb_close_OnClick(ByVal sender As Object)

        'Close form
        Me.Close()

    End Sub

    ''' <summary>
    ''' Check if it is VGA or QVGA
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function _isVGA() As Boolean

        Try

            'Return the output
            Return StedySoft.SenseSDK.DrawingCE.Resolution.ScreenIsVGA

        Catch ex As Exception

            'Throw exception if any other error caught
            Throw New Exception(ex.Message)

        End Try

    End Function

#End Region

End Class